package com.szl.yeb.controller;

import com.szl.yeb.common.constant.MsgConstant;
import com.szl.yeb.common.PageResult;
import com.szl.yeb.common.R;
import com.szl.yeb.entity.Employee;
import com.szl.yeb.service.EmployeeService;
import com.szl.yeb.service.SalaryService;
import com.szl.yeb.utils.ResponseProcessor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 员工账套
 *
 * @author szl
 * @since 1.0.0
 */
@RestController
@RequestMapping("/salary/sobcfg")
@Api(tags = "员工账套管理接口(SalarySobCfgController)")
public class SalarySobCfgController {
	@Autowired
	private SalaryService salaryService;

	@Autowired
	private EmployeeService employeeService;

	@ApiOperation("获取所有员工及其账套信息")
	@GetMapping("/")
	public PageResult getEmployeesWithSalaryByPage(@RequestParam(defaultValue = "1") Integer currentPage,
												   @RequestParam(defaultValue = "10") Integer size){
		return employeeService.getPage(currentPage,size);
	}

	@ApiOperation("获取所有员工及其账套信息")
	@GetMapping("/salary")
	public R<Object> getSalaries(){
		return R.obj(salaryService.list());
	}

	@ApiOperation("更新员工账套信息")
	@PutMapping("/")
	public R<Object> updateEmployeeSalary(@RequestBody Employee employee){
		return ResponseProcessor.getResWithMsg(employeeService.updateById(employee), MsgConstant.UPDATE);
	}
}